package com.weizhi.server.service.impl;

import com.weizhi.server.dto.CategoryDto;
import com.weizhi.server.dto.CourseDto;
import com.weizhi.server.entity.CourseCategory;
import com.weizhi.server.mapper.CourseCategoryMapper;
import com.weizhi.server.service.CourseCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;



@Service
public class CourseCategoryServiceImpl implements CourseCategoryService {

    @Resource
    private CourseCategoryMapper courseCategoryMapper;


    @Transactional
    @Override
    public void saveCourseCategory(Long courseId, List<Long> categoryIdList) {
        for(Long categoryId: categoryIdList) {
            CourseCategory courseCategory = new CourseCategory();
            courseCategory.setCourseId(courseId);
            courseCategory.setCategoryId(categoryId);
            courseCategoryMapper.insert(courseCategory);
        }
    }
}
